#!/bin/sh


#
# Define vars
#
SERVER=../p2_server/ibrc_server
CLIENT=../p2_client/ibrc_client
SLEEP_TIME=0.1

FOLDER=/tmp/ibrc/

mkdir -p $FOLDER

#killall ibrc_server
#killall ibrc_client

#rm -f $FOLDER/ibrc_*.log

#
# Start Server
#


# parent layer
$SERVER --name server0 -psl 6000 -pcl 5000 --log-file $FOLDER/ibrc_server0.log --info-file $FOLDER/ibrc_server0.info --raw-data-log-file $FOLDER/ibrc_server0.raw &
sleep $SLEEP_TIME

#first layer childs
$SERVER --name server1 -c -psc 6000 -psl 6001 -pcl 5001 --log-file $FOLDER/ibrc_server1.log --info-file $FOLDER/ibrc_server1.info --raw-data-log-file $FOLDER/ibrc_server1.raw &
sleep $SLEEP_TIME
$SERVER --name server2 -c -psc 6000 -psl 6002 -pcl 5002 --log-file $FOLDER/ibrc_server2.log --info-file $FOLDER/ibrc_server2.info --raw-data-log-file $FOLDER/ibrc_server2.raw &
sleep $SLEEP_TIME

#second layer childs
$SERVER --name server3 -c -psc 6001 -psl 6003 -pcl 5003 --log-file $FOLDER/ibrc_server3.log --info-file $FOLDER/ibrc_server3.info --raw-data-log-file $FOLDER/ibrc_server3.raw &
sleep $SLEEP_TIME
$SERVER --name server4 -c -psc 6001 -psl 6004 -pcl 5004 --log-file $FOLDER/ibrc_server4.log --info-file $FOLDER/ibrc_server4.info --raw-data-log-file $FOLDER/ibrc_server4.raw &
sleep $SLEEP_TIME

$SERVER --name server5 -c -psc 6002 -psl 6005 -pcl 5005 --log-file $FOLDER/ibrc_server5.log --info-file $FOLDER/ibrc_server5.info --raw-data-log-file $FOLDER/ibrc_server5.raw &
sleep $SLEEP_TIME
$SERVER --name server6 -c -psc 6002 -psl 6006 -pcl 5006 --log-file $FOLDER/ibrc_server6.log --info-file $FOLDER/ibrc_server6.info --raw-data-log-file $FOLDER/ibrc_server6.raw &
sleep $SLEEP_TIME
